package mop.exception;

/**
 * Exception class to be thrown when a duplicate has been encountered
 * 
 * @author	 MOP Team 7
 */
public class IllegalDuplicationException extends Throwable 
{

	/**
	 * Initializes an IllegalDuplicationException with the passed id
	 * 
	 * @param id	The id that's duplicate
	 *  
	 * @effect sets the id
	 */
	public IllegalDuplicationException(String id)
	{
		this.setid(id);
	}
	
	/**
	 * Return a error message that can be used by the gui
	 * @return An error message describing the incorrect id
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append("The following id already exists ! :: ");
		sb.append(this.id);
		return sb.toString();
	}
	
	 /**
	  * Set the id
	  * 
	  * @param id
	  *  The id that's causing trouble
	  *  
	  * @post The id is set to the passed one
	  */
	 private void setid(String id) 
	 {

		 this.id = id;
	 }
	
	/**
	 * Weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The id thats causing the problem
	 */
	private String id;
	
}